<template>
  <div class="app-container">
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="transactionAccount"
        label="帐户"
        width="100"/>
      <el-table-column
        prop="debentureCode"
        label="债券代码"
        width="100"/>
      <el-table-column
        prop="amount"
        label="数量">

      </el-table-column>
      <el-table-column
        label="交易方向">
        <template slot-scope="scope">
          <div v-if="scope.row.transactionDirection == 1 " class="bottom-wrapper mt60">
            <el-button class="button-wrapper">
              <div class="v-button white" >买入</div>
            </el-button>
          </div>
          <div v-if="scope.row.transactionDirection == 2 " class="bottom-wrapper mt60">
            <el-button class="button-wrapper">
              <div class="v-button white">卖出</div>
            </el-button>
          </div>
        </template>
      </el-table-column>

      <el-table-column
        prop="transactionDate"
        label="交易日期"/>

      <el-table-column
        prop="price"
        label="单价">
      </el-table-column>

      <el-table-column
        prop="settlementAmount"
        label="结算金额">
      </el-table-column>

    </el-table>


    <div class="pagination-container">
      
    <el-pagination
      :current-page.sync="page"
      :total="total"
      :page-size="limit"
      class="pagination"
      layout="prev, pager, next"
      @current-change="handleCurrentChange"/>
    </div>

  </div>
</template>

<script>
import transactiontable from '@/api/transactiontable'
import { getToken } from '@/utils/auth'

export default {
  data() {
    return {
      transactionControlSearchVo: {},
      tableData: [],
      page: 1, // 当前页
      limit: 10, // 每页个数
      total: 1 // 总页码
    }
  },
  created() {
    this.search()
    console.log(getToken())
  },
  methods: {
    onSubmit() {
      this.$message('submit!')
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      })
    },
    handleCurrentChange(val){
      this.page = val;
      this.search();
    },

    search() {
      transactiontable.pageBySearch(this.page, this.limit).then(response => {
        this.tableData = response.data.records
        this.total = response.data.total
      })
    }
  }
}
</script>

<style scoped>
.search-input{
  margin-left: 900px;
}
.search-from{
  margin-left: 100px;
}
.sreach-button{
  margin-left: 550px;
}
</style>
